<template>
	<view class="body">
		<uni-popup ref="popup1" type="dialog">
			<uni-popup-dialog type="warning" content="确定取消会议吗? " @confirm="cancel"></uni-popup-dialog>
		</uni-popup>
		<uni-section title="会议信息" padding="20rpx 40rpx;">
			<view class="row-input">
				<text class="star">*</text>
				<text class="label">会议室:</text>
				<input type="text" class="editor no-border" disabled :value="roomName" />
			</view>

			<view class="row-input mt-10">
				<text class="star">*</text>
				<text class="label">会议标题:</text>
				<input type="text" class="editor no-border" disabled placeholder="暂无" :value="title" />
			</view>

			<view class="row-input mt-10">
				<text class="star">*</text>
				<text class="label">会议日期:</text>
				<picker class="date-wrap" mode="date" :value="date" disabled>
					<view class="editor  no-border">{{date}}</view>
				</picker>
			</view>

			<view class="row-input mt-10">
				<text class="star">*</text>
				<text class="label">会议时间:</text>
				<view class="editor  no-border">{{begin_time}} - {{end_time}}</view>
			</view>

			<view class="row-input mt-10">
				<text class="star hide">*</text>
				<text class="label">概要:</text>
				<textarea class="editor remark  no-border" :value="metting_remark" placeholder="暂无"
					style="padding: 20rpx 20rpx;" disabled></textarea>
			</view>
		</uni-section>

		<!-- <uni-section title="参会成员" padding="20rpx 40rpx;" class="mt-10">
			<view class="member-wrap">
				张三、李四、王五
			</view>
		</uni-section> -->

		<button type="default" class="btn" v-if="isMine==true" @click="toEdit">修改</button>
		<button type="default" class="btn" v-if="isMine==true" @click="cancelShow">取消会议</button>
	</view>
</template>

<script>
	import cfg from '@/utils/config.js'
	import time_util from '@/utils/time_util.js'
	export default {
		data() {
			return {
				id: null,

				roomName: '',
				title: '',
				date: '',
				begin_time: '',
				end_time: '',
				metting_remark: '',
				isMine: null
			}
		},
		onLoad(param) {
			this.id = param.id
		},
		onShow() {
			this.getDetail()
		},
		methods: {
			getDetail() {
				if (!this.id) {
					return
				}
				uni.request({
					url: cfg.host + 'meeting/get/' + this.id,
					method: 'GET',
					success: (res) => {
						if (res.data.code == 0) {
							let data = res.data.data
							this.roomName = data.roomName
							this.title = data.title
							this.metting_remark = data.desc

							this.date = time_util.getMD(data.beginTime)
							this.begin_time = time_util.getHM(data.beginTime)
							this.end_time = time_util.getHM(data.endTime)
							this.isMine = data.isMine
						}
					}
				})
			},
			toEdit() {
				uni.navigateTo({
					url: '/pages1/metting/reserve/detail_edit?id=' + this.id
				})
			},
			cancelShow() {
				this.$refs.popup1.open()
			},
			cancel() {
				if (!this.id) {
					return
				}
				uni.request({
					url: cfg.host + 'meeting/cancel/' + this.id,
					method: 'POST',
					success: (res) => {
						if (res.data.code == 0) {
							uni.showToast({
								title: '取消成功',
								icon: 'success'
							})
							setTimeout(() => {
								uni.navigateBack()
							}, 1000)
						} else {
							let msg = res.data.msg || '取消失败'
							uni.showToast({
								title: msg,
								icon: 'error'
							})
						}
					},
					fail: () => {
						uni.showToast({
							title: '取消失败',
							icon: 'error'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.date-wrap {
		width: 200rpx;
	}

	.time-spe {
		margin-left: 20rpx;
		margin-right: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	.remark {
		height: 150rpx;
		border: 1rpx solid #f4f4f4;
		box-sizing: border-box;
	}

	.member-wrap {
		font-size: 28rpx;
	}
</style>